package com.mapreduce.combinerwc;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import javax.naming.ldap.PagedResultsControl;
import java.io.IOException;

public class WordCountCombiner  extends Reducer
<Text, IntWritable,Text, IntWritable>{
    //Combiner输出值
    private IntWritable value= new IntWritable();
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        //求和
        int sum =0;
        for (IntWritable value : values) {
            sum+=value.get();
        }
        value.set(sum);
       //写出
       context.write(key,value);
    }
}
